Hello all, I try to count all histories of a certain type for all objects in my module from a begining date to a end date. But, I'm bloqued with sorting the counts by date of history. Here is my code, but if h.date are not the same for each object, how can I count the modifications by h.date ?
int Nb_valide_CCTP_new, Nb_vide_CCTP_new, Nb_vide_CCTP_old, Nb_valide_CCTP_old
/***********************************
Historique
***********************************/
void Historique (Object o, Module m, History h)
{
string ancien = h.plainOldValue
string nouveau = h.plainNewValue
if (ancien == "Validé") Nb_valide_CCTP_old ++
else if ((ancien == "")||(ancien == "(Default Value)")) Nb_vide_CCTP_old ++
if (nouveau == "Validé") Nb_valide_CCTP_new ++
else if ((nouveau == "")||(ancien == "(Default Value)")) Nb_vide_CCTP_new ++
}
/***********************************
MAIN
***********************************/
Module m = current Module
Object o
string nommodule = m."Name"
Date D_Debut
b_recent = getMostRecentBaseline(m)
if(b_recent != null) D_Debut = dateOf(b_recent)
else D_Debut = m."Created On"
int I_Debut = intOf(D_Debut)
Date D_Fin = today
int I_Fin = intOf(D_Fin)
Nb_valide_CCTP_old = Nb_vide_CCTP_old = 0
Nb_valide_CCTP_new = Nb_vide_CCTP_new = 0
Exigence_CCTP = find (m, "AE Req Id.")
if (Exigence_CCTP != null) {
for o in (m) do {
AttrDef exigences = find (m, "AE Type Objet ")
string Exigence = ""
if (exigences != null) Exigence = o."AE Type Objet "
if (Exigence == "Requirement") {
History h
for h in o do
{
HistoryType ht = h.type
string S_Hist = stringOf(h.date, userLocale, "dd/MM/yyyy")
Date D_Hist = date(S_Hist)
int I_Hist = intOf(D_Hist)
if ((ht==modifyObject)&&(h.attrName == "AS Suivi") &&(I_Debut <= I_Hist)&&(I_Hist <= I_Fin))
{
Historique (o, m, h)
}
}
}
}
print Nb_valide_CCTP_old " " Nb_valide_CCTP_new " " Nb_vide_CCTP_old " " Nb_vide_CCTP_new "\n"
}
Does someone has an idea to sort these counts ? Estebell - Fri Jun 17 08:48:59 EDT 2016 |
Re: Sorting by history dates Sorting in DXL usually comes down to a skip list, where you put integer or string keys in. So I would do an intOf ( date ) and put all History entries inside the skip list... Then loop over the skip list. Regards, Mathias |
Re: Sorting by history dates
Below is an example of using a Skip to sort strings...the same principle can be used for sorting other data types...if sorting non-string types, be sure to declare the Skip as:
bool populateSkipWithStringLines(Skip &theSkip, string theString)
{
if (null(theSkip)) return(false)
Regexp aLine = regexp ".*"
while (aLine(theString) && (theString != ""))
{
string theLine = theString[match 0]
theString = theString[((end 0)+2):]
if (theLine != "") put(theSkip, theLine, theLine)
}
return(true)
}
Skip sortedList = createString
string inputString =
"d
g
a
f
r
z"
if (populateSkipWithStringLines(sortedList, inputString))
{
string aLine
for aLine in sortedList do print aLine "\n"
}
delete(sortedList)
|
Re: Sorting by history dates Hi, Thank's a lot for your advices, I 've got the history I want in my SkipList. Now I have to analyse the data.
Estelle |